package top.hkyzf.study.leetcode.string;

import org.junit.Test;

import java.util.Arrays;

/**
 * description: 
 * @author zhufeng
 * @date 2024/3/7 0007 10:50
 * @version V1.0
 */
public class 找出字符串的可整除数组_2575 {
    public int[] divisibilityArray(String word, int m) {
        int length = word.length();
        int[] rtn = new int[length];
        long remained = 0;
        for (int i = 0; i < length; i++) {
            String cur = word.substring(i, i+1);
            long i1 = (remained * 10 + Long.parseLong(cur)) % m;
            if (i1 == 0) {
                rtn[i] = 1;
                remained = 0;
            } else {
                remained = i1;
            }
        }
        return rtn;
    }

    @Test
    public void testDivisibilityArray () {
        String word = "10000000001000000000301999999996100000000091999999990799999999382999999990100000000099999999911";
        int m = 1000000000;
        int[] ints = divisibilityArray(word, m);
        Arrays.stream(ints).forEach(System.out::println);
    }
}
